p, e = map(int, input().split())
edges = []
for _ in range(e):
    edges.append(tuple(map(int, input().split())))


class UnionFind:
    def __init__(self, n):
        self.fa = list(range(n + 1))

    def find(self, x):
        if self.fa[x] != x:
            self.fa[x] = self.find(self.fa[x])
        return self.fa[x]

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return False
        self.fa[root_y] = root_x
        return True


uf = UnionFind(p)
heap = []
